import cv2

if __name__ == '__main__':
    video = cv2.VideoCapture("./img/up.mp4")
    fps = video.get(cv2.CAP_PROP_FPS)
    success,frame = video.read()
    while success:
        cv2.imshow("frame",frame)
        success, frame = video.read()

        # 按键退出
        if cv2.waitKey(1) == ord(" "):
            break
        # 1000ms = 1s
        # 1000 / fps 计算每一帧需要的时间
        cv2.waitKey(int(1000 / int(fps)))

    # 释放资源
    video.release()
    # 关闭所有窗口
    cv2.destroyAllWindows()
